import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "untitled.settings")
import django

django.setup()

from django.test import TestCase
from mysql_demo.models import Subject, Student
import datetime

# Create your tests here.


# Student.objects.create(sname='zhangsan', sgender='1', sage=20)
# Student.objects.create(sname='lisi', sgender='1', sage=23)
# Student.objects.create(sname='wangwu', sgender='0', sage=19)

# s1 = Student.objects.get(sname='zhangsan')
# s2 = Student.objects.get(sname='lisi')
# s3 = Student.objects.get(sname='wangwu')
# Subject.objects.create(sub_name='python', sub_scores=69, sub_time=datetime.date(2019, 8, 1), sub_stu=s1)
# Subject.objects.create(sub_name='python', sub_scores=80, sub_time=datetime.date(2019, 8, 1), sub_stu=s2)
# Subject.objects.create(sub_name='python', sub_scores=85, sub_time=datetime.date(2019, 8, 1), sub_stu=s3)
# Subject.objects.create(sub_name='UI', sub_scores=49, sub_time=datetime.date(2019, 9, 1), sub_stu=s1)
# Subject.objects.create(sub_name='UI', sub_scores=60, sub_time=datetime.date(2019, 9, 1), sub_stu=s2)
# Subject.objects.create(sub_name='C++', sub_scores=74, sub_time=datetime.date(2019, 10, 1), sub_stu=s3)
stu1 = Student.objects.filter(subject__sub_name='python')
print(stu1)